package main

import (
	"google.golang.org/grpc"
	"grpcpro/helper"
	"grpcpro/services"
	"log"
	"net"
)

const (
	Address = "127.0.0.1:8888" // Address gRPC服务地址
)

func main() {
	rpcServer := grpc.NewServer(grpc.Creds(helper.GetServeCreds())) //实例化grpc Server
	//创建带ca证书验证的服务端
	services.RegisterProdServiceServer(rpcServer, new(services.ProdService))           //注册商品服务
	services.RegisterOrderServiceServer(rpcServer, new(services.OrderService))         //注册订单服务
	services.RegisterUserScoreServiceServer(rpcServer, new(services.UserScoreService)) //用户积分服务
	listen, _ := net.Listen("tcp", Address)                                            //设置传输协议和监听地址
	log.Println("Listen on " + Address + " with TLS")
	rpcServer.Serve(listen)
}
